package com.ssy.lingxi.purchase.entity.tender;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 投标会员
 * @author jw.chen
 * @version 2.0.0
 * @date 2021/3/11
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "purchase_invite_tender_member")
public class InviteTenderMember implements Serializable {
    private static final long serialVersionUID = 3103225894239800543L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="invite_tender_member_seq")
    @SequenceGenerator(sequenceName="purchase_invite_tender_member_seq", name="invite_tender_member_seq",allocationSize = 1)
    private Long id;

    /**
     * 招标id
     */
    @JsonIgnore
    @ManyToOne(cascade = {CascadeType.PERSIST})
    @JoinColumn(name="inviteTenderId",referencedColumnName = "id")
    private InviteTender inviteTender;

    /**
     * 投标外部状态: SubmitTenderOutStatusEnum.class
     */
    @Column(columnDefinition = "int", nullable = false)
    private Integer submitTenderOutStatus = 0;

    /**
     * 投标内部状态: SubmitTenderInStatusEnum.class
     */
    @Column(columnDefinition = "int", nullable = false)
    private Integer submitTenderInStatus = 0;

    /**
     * 投标报名
     */
    @OneToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    @JoinColumn(name="submitTenderRegisterId",referencedColumnName = "id")
    private SubmitTenderRegister submitTenderRegister;

    /**
     * 资格证明附件
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTenderMember", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<SubmitTenderQualificationsFile> qualificationsFile;

    /**
     * 投标信息
     */
    @OneToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinColumn(name="submitTenderId",referencedColumnName = "id")
    private SubmitTender submitTender;

    /**
     * 投标编号
     */
    @Column(columnDefinition = "varchar(20)")
    private String code;

    /**
     * 投标时间
     */
    @Column(columnDefinition = "int8")
    private Long submitTenderTime;

    /**
     * 提交资格预审时间
     */
    @Column(columnDefinition = "int8")
    private Long submitQualificationsCheckTime;

    /**
     * 会员id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long memberId;

    /**
     * 会员名称
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    private String memberName;

    /**
     * 会员类型名称
     */
    @Column(columnDefinition = "varchar(50)")
    private String memberTypeName;

    /**
     * 会员角色id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long memberRoleId;

    /**
     * 会员角色名称
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    private String memberRoleName;

    /**
     * 是否下属会员
     */
    @Column(columnDefinition = "boolean", nullable = false)
    private Boolean isSubMember;

    /**
     * 是否发送招标
     */
    @Column(columnDefinition = "boolean", nullable = false)
    private Boolean isSend;

    /**
     * 会员等级
     */
    @Column(columnDefinition = "int")
    private Integer level;

    /**
     * 会员等级名称
     */
    @Column(columnDefinition = "varchar(50)")
    private String levelTag;

    /**
     * 是否中标
     */
    @Column(columnDefinition = "boolean")
    private Boolean isWin;

    /**
     * 是否已投标
     */
    @Column(columnDefinition = "boolean")
    private Boolean isSubmit = false;

    /**
     * 评标信息(非在线评标)
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTenderMember", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<EvaluationTenderOffline> evaluationTenderOfflineList;

    /**
     * 修正总分
     */
    @Column(columnDefinition = "decimal")
    private Double correctScore;

    /**
     * 流程任务id
     */
    @Column(columnDefinition = "varchar(100)")
    private String taskId;
}
